package com.ktjiaoyu.utils;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.filter.PropertyPreFilter;
import com.ktjiaoyu.entity.SysRole;
import com.ktjiaoyu.utils.fastjson2.FastJson2SensitivePropFilter;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

public class test {
    public static void main(String[] args) {
        Set<String> sensitiveFields = new HashSet<>();
        sensitiveFields.add("roleName");
        sensitiveFields.add("code");
        PropertyPreFilter filter = new FastJson2SensitivePropFilter(sensitiveFields);
        SysRole sysRole = new SysRole(1L, "管理员", "管理员", 1L, new Date(), 1L, new Date());
        String json = JSON.toJSONString(sysRole, filter);
        System.out.println(json);
    }
}